from django.contrib import admin

# Register your models here.
from .models import User, Certification
from .certification_action import CertificationAction
import xadmin
from xadmin import views

class UserAdmin(object):
    list_display = ('username', 'real_name', 'sex', 'age', 'email', 'phone_number', 'is_auth')
    readonly_fields = ('username', 'real_name', 'sex', 'age', 'email', 'id_card', 'phone_number',
                       'password', 'last_name', 'first_name', 'last_login', 'date_joined',
                       'summary', 'avatar', 'fan_count', 'follow_count', 'id',)
    search_fields = ('username', 'real_name', 'phone_number', 'email')
    style_fields = {'user_permissions': 'm2m_transfer', 'groups': 'm2m_transfer'}
    model_icon = 'fa fa-user'


class CertificationAdmin(object):
    list_display = ('user', 'certification_time', 'id_card_positive', 'id_card_back',)
    show_detail_fields = ('id_card_positive', 'id_card_back',)
    actions = (CertificationAction,)
    global_actions = []


class BaseSetting(object):
    enable_themes = True
    use_bootswatch = True


class GlobalSettings(object):
    site_title = 'Aurora后台管理系统'
    site_footer = 'Aurora原创音乐者交流平台'
    menu_style = 'accordion'


xadmin.site.unregister(User)
xadmin.site.register(User, UserAdmin)
xadmin.site.register(Certification, CertificationAdmin)

xadmin.site.register(views.BaseAdminView, BaseSetting)
xadmin.site.register(views.CommAdminView, GlobalSettings)